package com.longge;

public class MaxScore {
    public int maxScore(String s) {

        char[] chars = s.toCharArray();
        int max = 0, left = 0, right = 0;
        for (char c : chars) {
            if (c == '1') right++;
        }
        for (int i = 0; i < chars.length-1; i++) {
            char aChar = chars[i];
            if (aChar == '0') {
                left++;
            } else {
                right--;
            }
            max = Math.max(max, left + right);
        }
        return max;

    }

    public static void main(String[] args) {
        int i = new MaxScore().maxScore("011101");
        System.out.println(i);
    }
}
